<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/hospital_token.jsp"%>
<%
    // 新建标签
    String labelName = input.getDesc("label_name", "").trim();
    if (labelName.isEmpty()) {
        ErrcodeUtil.setErrcode(msg, ErrcodeUtil.FAILURE);
        Tools.encryptPrint(out, msg);
        return;
    }
    HospitalLabel hospitalLabel = LabelUtil.getHospitalLabelByName(hospital, labelName);
    if (hospitalLabel != null) {
        msg.setErrcodeAndErrmsg(ErrcodeUtil.FAILURE, "该标签名已存在");
        Tools.encryptPrint(out, msg);
        return;
    }
    hospitalLabel = new HospitalLabel();
    hospitalLabel.setName(labelName);
    hospitalLabel.setCategory(0);
    hospitalLabel.setHospital(hospital);
    Integer key = (Integer)DBTools.db("basedb").addItem(hospitalLabel);
    if (key == null) {
        ErrcodeUtil.setErrcode(msg, ErrcodeUtil.ADD_FAILED);
    } else {
        Map data = new HashMap();
        data.put("id", key);
        msg.put("data", data);
    }
    Tools.encryptPrint(out, msg);
%>
